/*
 * @Author: your name
 * @Date: 2022-04-12 21:28:06
 * @LastEditTime: 2022-04-12 23:03:43
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /safe_transmission_platform/test/proto_test.cc
 */
#include "codec.h"
#include "codecFactory.h"
#include <memory>
#include <iostream>
int main()
{
    daniel::Factory::ptr factory(new daniel::RequestFactory);
    daniel::RequestCodec::ptr request;
    request.reset(dynamic_cast<daniel::RequestCodec*>(factory->createObject()));
    request->initMsg(1,"123","256","daniel","data");
    std::cout<<request->encodeMsg()<<std::endl;
    // std::cout<<request->decodeMsg()<<std::endl;
    daniel::RequestCodec::ptr request2;
    request2.reset(dynamic_cast<daniel::RequestCodec*>(factory->createObject()));
    request2->initMsg(request->encodeMsg());
    RequestMsg* msg=(RequestMsg*)request2->decodeMsg();
    std::cout<<"cmdType="<<msg->cmdtype()<<"\t"<<"clientId="<<msg->clientid()<<"\t"\
    <<"serverId="<<msg->serverid()<<"\t"<<"sign="<<msg->sign()<<"\t"<<"data="<<msg->data()<<std::endl;
    return 0;
}